package com.byjh.web.controller.app;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.byjh.common.annotation.Log;
import com.byjh.common.core.controller.BaseController;
import com.byjh.common.core.domain.AjaxResult;
import com.byjh.common.enums.BusinessType;
import com.byjh.app.domain.App;
import com.byjh.app.service.IAppService;
import com.byjh.common.utils.poi.ExcelUtil;
import com.byjh.common.core.page.TableDataInfo;

/**
 * 应用Controller
 * 
 * @author Dhq
 * @date 2025-01-20
 */
@RestController
@RequestMapping("/app/application")
public class AppController extends BaseController
{
    @Autowired
    private IAppService appService;

    /**
     * 查询应用列表
     */
    @GetMapping("/list")
    public TableDataInfo list(App app)
    {
        startPage();
        List<App> list = appService.selectAppList(app);
        return getDataTable(list);
    }

    /**
     * 获取应用详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appService.selectAppById(id));
    }

    /**
     * 新增应用
     */
    @Log(title = "应用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody App app)
    {
        return toAjax(appService.insertApp(app));
    }

    /**
     * 修改应用
     */
    @Log(title = "应用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody App app)
    {
        return toAjax(appService.updateApp(app));
    }

    /**
     * 删除应用
     */
    @Log(title = "应用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(appService.deleteAppById(id));
    }
}
